OpenDeskAcc
Str255 daName ; p-string name of DA to open returns driver reference number (if successful)
() menu. It loads the DA into memory (if not already there) and passes
control to it.
daName is the address of a pascal-style length-prefixed string containing
the name of the DA to open. It is normally a value obtained via
Returns: a short; the driver reference number of the just opened DA. If the call fails, the return value is un defined, so don't depend on this value.
Notes: OpenDeskAcc should be used in all interactive applications to enable the user to access DAs (i.e., all interactive applications).
Note: Some older DAs might leave their windows active. It is wise to Before making the call, you may want to enable standard menu items such
as Close, Undo, etc. You also may wish to disable all other menu items (as recommended in IM).
In addition, you will need a piece of code to close the DA. When the user
choses Close from your File menu, and the frontmost window is not yours, you should call CloseDeskAcc. Your application should also call SystemEdit to take care of Edit menu selections for DAs. The example below outlines the overhead and general sequence of
Example
#include <Menus.h>
#include <Desk.h>
void DoAboutMyProg(void);
/*... when setting up the menus ...*/
# define APPLE_RES_ID 1
# define APPLE_MENU 1
appleMenu = NewMenu( APPLE_RES_ID, "\p\024" ); /* create apple menu */
AddResMenu( appleMenu, 'DRVR' ); /* Add DA list */ InsertMenu( appleMenu, 0 ); /* install in menu bar */ /*... in the event loop ... */
long mr; /* MenuSelect() return code */
if ( theEvent.what == mouseDown ) {
case inMenuBar:
mr = MenuSelect( theEvent.where ); /* user interaction */ if ( HiWord( mr ) == APPLE_MENU ) { /* in apple menu? */ DoAboutMyProg(); /* About MyProg... */
break;
} /* else must be DA */
/* disable unneeded items */
EnableItem( fileMenu, fmClose ); /* enable Close item */ /* get DA name */
GetPort( &savePort ); /* a precaution */ SetPort( savePort ); /* some insurance */ EnableItem( editMenu, emOptions ); /* re-enable items */ break;
}
case inDrag:
/* ... etc ... */
}
}
}